﻿using System.Collections.Generic;
using System.Text;

namespace FinalPointSet.Model.Model.FieldMapping
{
    public class Table
    {
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; } = string.Empty;
        /// <summary>
        /// 库名
        /// </summary>
        public string Database { get; set; } = string.Empty;
        /// <summary>
        /// 备注
        /// </summary>
        public string Comment { get; set; } = string.Empty;
        /// <summary>
        /// 字段
        /// </summary>
        public List<Field> Fields { get; set; } = new();
        /// <summary>
        /// 额外字段
        /// </summary>
        public List<Field> ExtraFields { get; set; } = new();

        public override string? ToString()
        {
            StringBuilder sb = new();
            sb.AppendLine($"Name={Name},Database={Database},Comment={Comment}");
            sb.AppendLine("Fields");
            foreach (Field field in Fields)
            {
                sb.AppendLine(field.ToString());
            }
            sb.AppendLine("\nExtraFields");
            foreach (Field field in ExtraFields)
            {
                sb.AppendLine(field.ToString());
            }
            return sb.ToString();
        }
    }
}
